//
//  SIDownloadManager.h
//  MKTestDownload
//
//  Created by ChenYu Xiao on 12-6-13.
//  Copyright (c) 2012年 sumi. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "MKNetworkKit.h"
@class SIBreakpointsDownload;
@class SIDownloadManager;
/// 改变progress
typedef void (^SIDownloadManagerProgress)(SIDownloadManager *siDownloadManager,SIBreakpointsDownload *paramOperation,double paramProgress);
///下载完成时
typedef void (^SIDownloadManagerDidComplete)(SIDownloadManager *siDownloadManager,SIBreakpointsDownload *paramOperation);
///下载错误
typedef void (^SIDownloadManagerError)(SIDownloadManager *siDownloadManager,SIBreakpointsDownload *paramOperation,NSError *paramError);


//Define the protocol for the delegate
@protocol SIDownloadManagerDelegate<NSObject>
// 改变progress
- (void)downloadManager:(SIDownloadManager *)siDownloadManager 
          withOperation:(SIBreakpointsDownload *)paramOperation 
         changeProgress:(double)paramProgress;
//下载完成时
- (void)downloadManagerDidComplete:(SIDownloadManager *)siDownloadManager 
                     withOperation:(SIBreakpointsDownload *)paramOperation;
//下载错误
- (void)downloadManagerError:(SIDownloadManager *)siDownloadManager
                     withOperation:(SIBreakpointsDownload *)paramOperation
                   withError:(NSError *)paramError;
//下载任务已经存在
- (void)downloadManagerDownloadExist:(SIDownloadManager *)siDwonloadManager
                             withOperation:(SIBreakpointsDownload *)paramOperation;
//下载文件已经存在
- (void)downloadManagerDownloadDone:(SIDownloadManager *)siDownloadManager
                            withOperation:(SIBreakpointsDownload *)paramOperation;
//暂停下载
- (void)downloadManagerPauseTask:(SIDownloadManager *)siDownloadManager 
                         withOperation:(SIBreakpointsDownload *)paramOperation;
@end

@interface SIDownloadManager : MKNetworkEngine
{
    id<SIDownloadManagerDelegate> delegate;
}

@property (nonatomic, weak) id  <SIDownloadManagerDelegate> delegate;
//@property (nonatomic,copy)SIDownloadManagerDidComplete managerDidComplete;
//@property (nonatomic,copy)SIDownloadManagerProgress managerProgress;
//@property (nonatomic,copy)SIDownloadManagerError managerError;
+ (id)sharedSIDownloadManager;

- (void)cancelAllDonloads;

- (void)addDownloadFileTaskInQueue:(NSString *)paramURL 
                        toFilePath:(NSString *)paramFilePath
                  breakpointResume:(BOOL)paramResume
                       rewriteFile:(BOOL)paramRewrite DEPRECATED_ATTRIBUTE;

- (void)addDownloadFileTaskInQueue:(NSString *)paramURL
                        toFilePath:(NSString *)paramFilePath
                  breakpointResume:(BOOL)paramResume
                       rewriteFile:(BOOL)paramRewrite
                       DidComplete:(SIDownloadManagerDidComplete)didComplete
                          Progress:(SIDownloadManagerProgress)managerProgress
                             Error:(SIDownloadManagerError)managerError;


- (void)cancelDownloadFileTaskInQueue:(NSString *)paramURL;

- (NSArray *)allDownloads;


@end


